
public class WeatherDisplay implements Observer {

    private Subject subject;
    private float temperature;

    public WeatherDisplay(Subject subject) {
        this.subject = subject;
        subject.registerObserver(this);
    }

    public void update(float temperature) {
        this.temperature = temperature;
    }

    public void display() {
        System.out.println("当前的温度为：" + temperature);
    }

}